$(function(){
    var searchKey = antUtil.getParamFromUrl('searchKey');
    searchKey = antUtil.base64.decode(searchKey);
    $('#searchKey').val(searchKey);
    Init(searchKey);

    //搜索按钮绑定事件
    $('#searchBtn').click(function(){
        searchKey = $('#searchKey').val();
        Init(searchKey);
    });
});

function Init(searchKey){
    var tokenId = antUtil.getSes('tokenId');

    $.ajax({
        url : "init/getPortalBusiData",
        type : 'GET',
        dataType : "json",
        data : {
            searchKey:searchKey,
            tokenId:tokenId
        },
        success : function(data) {
            var html ='';
            for(var i=0;i<data.length;i++){
                html+='<div class="contentPart">';
                html+='<h4>'+data[i].EN_NAME+'-'+data[i].BILLTYPE_NAME+'</h4>';
                html+='<p>凭证号：'+data[i].BILL_NO+'</p>';
                html+='<p>凭证日期：'+data[i].BILL_DATE+'</p>';
                html+='<p>凭证金额：'+data[i].PAY_MONEY+'</p>';
                html+='<p>摘要：</p>';
                html+='<p>收款人名称：'+data[i].PAYEE_ACCOUNT_NAME+'</p>';
                html+='<p>收款人账号：'+data[i].PAYEE_ACCOUNT_NO+'</p>';
                html+='<p>收款人开户行：'+data[i].PAYEE_ACCOUNT_BANK+'</p>';
                html+='<p>支出功能分类：'+data[i].TYPE_NAME+' </p>';
                html+='</div>';
            }

            html = html.replace(searchKey,'<font style="color:red">'+searchKey+'</font>');
            $(".content").html(html);

            var str = $('.content').html();
                var reg = new RegExp(""+searchKey+"","g");
                var result = str.replace(reg,"<font style='color:#F00;font-weight:700;'>"+searchKey+"</font>");
                $('.content').html(result);

        }
    })
}